// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_QC_IQC
// * CreateDate    : 2014-03-27 22:08:47
// * Creater       : CodeSmith
// * LastChangeDate: 2014-03-27 22:08:47
// * LastChanger   : 2014-03-27 22:08:47
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Qc
{
/// <summary>
    /// QcIqc
    /// </summary>
    public partial class QcIqcBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objQcIqcEntity">Entity</param>
        /// <returns>Entity</returns>
        public static QcIqcEntity GetQcIqc(QcIqcEntity objQcIqcEntity)
        {
            return DataAccess.SelectSingle<QcIqcEntity>(objQcIqcEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objQcIqcEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertQcIqc(QcIqcEntity objQcIqcEntity)
        {
            return DataAccess.Insert(objQcIqcEntity);
        }

        public static bool InsertQcIqc(List<QcIqcEntity> objQcIqcEntityList)
        {
            return DataAccess.Insert(objQcIqcEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objQcIqcEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateQcIqc(QcIqcEntity objQcIqcEntity)
        {
            return DataAccess.Update(objQcIqcEntity);
        }

        public static bool UpdateQcIqc(List<QcIqcEntity> objQcIqcEntityList)
        {
            return DataAccess.Update<QcIqcEntity>(objQcIqcEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objQcIqcEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteQcIqc(QcIqcEntity objQcIqcEntity)
        {
            return DataAccess.Delete(objQcIqcEntity);
        }

        public static bool DeleteQcIqc(List<QcIqcEntity> objQcIqcEntityList)
        {
            return DataAccess.Delete<QcIqcEntity>(objQcIqcEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetQcIqcAll()
        {
            return DataAccess.SelectAllDataSet<QcIqcEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<QcIqcEntity> GetQcIqcAllList()
        {
            return DataAccess.SelectAll<QcIqcEntity>();
        }
        #endregion

        public static PurArvItemEntity GetArvItemForQcIqc(string iqcId)
        {
            string sql = @"select item.* from qc_iqc iqc
left join PUR_ARV arv on iqc.PUR_ARV_NO=arv.ARV_NO
left join PUR_ARV_ITEM item on arv.ARV_NO=item.ARV_NO
where iqc.IS_ACTIVE=1 and arv.IS_ACTIVE=1 and iqc.ID='{0}' and iqc.MATERIAL_ID=item.MATERIAL_ID";
            sql = string.Format(sql, iqcId);
            var items = DataAccess.Select<PurArvItemEntity>(sql);
            if (items == null || items.Count == 0)
            {
                return null;
            }
            else
            {
                return items[0];
            }
        }


	}
	
	
}	

